package com.liyuan.help_e.dao;

import com.liyuan.help_e.model.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserDao {
    @Select("select * from user where id = #{id}")
    User selectUserByUserId(Integer id);

    @Select("select * from user where username = #{username}")
    User selectUserByUsername(String username);

    @Insert({"insert into user set username = #{username},password = #{password},role = #{role.id},avatar_url = #{avatar_url}"})
    void insertUser(User user);

    @Update("update user set avatar_url = #{avatarUrl} where username = #{username}")
    void updateUserAvatarUrl(@Param("username") String username,
                             @Param("avatarUrl") String avatarUrl);
}
